package com.boat.sample.ddd.interfaces.mq;

import java.util.Map;

import org.springframework.stereotype.Component;

import com.boat.framework.common.util.JsonUtils;
import com.boat.starter.pulsar.annotation.PulsarMessageListener;
import com.boat.starter.pulsar.common.PulsarMessageExt;
import com.boat.starter.pulsar.core.PulsarListener;

import lombok.extern.slf4j.Slf4j;

/**
 * mq消息监听
 * @PulsarMessageListener(topic = "${topics.boatTopic}")
 * 同：@PulsarMessageListener(topic = "persistent://pulsar-mmqmqn8amqmx/boat/boat_sample_ddd")
 * @author 周江
 *
 */
@Slf4j
@Component
@PulsarMessageListener(topic = "${topics.boatTopic}", tags = "${topics.boatTopicTags}")
public class DemoMessageListener2 implements PulsarListener<String> {
	@Override
	public boolean onMessage(PulsarMessageExt<String> message) throws Exception {
		Map<String, Object> header= message.getHeaders();
		String body = message.getBody();
		log.info(">>>>>>>>收到消息2:header={}, body={}", JsonUtils.toJson(header), body);
		return true;
	}
}